//
//  AppealHandleHistoryItemModel.m
//  Utils
//
//  Created by enghou on 2018/6/22.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "AppealHandleHistoryItemModel.h"

@implementation AppealHandleHistoryItemModel
//@property(nonatomic,copy)NSString *time;
//
//@property(nonatomic,copy)NSString *event_desc;
//
//@property(nonatomic,copy)NSString *event_content;
//
//@property(nonatomic,copy)NSArray <FileItemModel *>*files;
//
//@property(nonatomic,assign)BOOL current;
//
//@property(nonatomic,assign)BOOL hasPrevious;//有前面的处理
//@property(nonatomic,assign)BOOL hasNext;//有后面的处理

-(instancetype)initWithSource:(NSDictionary *)source{
    self = [super initWithSource:source];
    if (self) {
        self.time = source[@"handleTime"];
        NSString *orgName = source[@"handleOrgName"];
        NSString *userName = source[@"handleUserName"];
        NSString *operation = source[@"operation"];
        self.event_desc = [NSString stringWithFormat:@"[%@] %@ %@",orgName,userName,operation];
        self.event_content = source[@"description"];
        if ([self.event_content length] > 0) {
            self.event_content = [NSString stringWithFormat:@"并留言: %@",self.event_content];
        }
        NSArray *files = source[@"files"];
        NSMutableArray *fs = [NSMutableArray array];
        for (NSDictionary *file in files) {
            FileItemModel *model = [[FileItemModel alloc]initWithSource:file];
            [fs addObject:model];
        }
        self.files = fs;
        CGSize descSize = [self.event_desc caculateSizeWithFont:[UIFont systemFontOfSize:14] MaxSize:CGSizeMake(ScreenWidth - 30, CGFLOAT_MAX)];
        CGSize contentSize = [self.event_content caculateSizeWithFont:[UIFont systemFontOfSize:14] MaxSize:CGSizeMake(ScreenWidth - 30, CGFLOAT_MAX)];
        self.height = 65 + descSize.height + contentSize.height;
        if ([self.files count] > 0) {
            self.height += 108;
        }
    }
    return self;
}


@end
